#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;


struct student{
	char num[8];
	int score;
};

int main(){
	int t;
	char c[8];
	struct student s[6];
	for(int i=0;i<6;i++){
	    cin>>s[i].num>>s[i].score;
	}
	for(int i=0;i<6;i++){
		for(int j=1;j<5;j++){
			if(s[i].score>s[j].score){
				t=s[j].score;
				s[j].score=s[i].score;
				s[i].score=t;
			/*	/*c[8]=s[j].num;
				s[j].num=s[i].num;
				s[i].num=c[8];*/
			}
		}
	}  
	for(int i=0;i<6;i++){
		//cout<<s[i].num<<s[i].score<<endl; 
		printf("%s %d\n",s[i].num,s[i].score);
		
	}
	
	
	
	
	return 0;
} 

